#ifndef MAINWINDOW_H
#define MAINWINDOW_H

#include <QMainWindow>
#include <QPixmap>
#include <QImage>
#include <QDesktopWidget>
#include <QTime>
#include <QTimer>
#include <QPaintEvent>
#include <QPainter>
#include <QByteArray>

#include <QKeyEvent>
#include <QTcpSocket>
#include <QHostAddress>

#include <iostream>
using namespace std;

#define MAX_PIC 30

namespace Ui {
class MainWindow;
}

class MainWindow : public QMainWindow
{
    Q_OBJECT

public:
    explicit MainWindow(QWidget *parent = 0);
    ~MainWindow();

    void paintEvent(QPaintEvent *);
    void keyPressEvent(QKeyEvent *ev);

    void recvMess(QByteArray buf);

    bool cmp_str(char str[], char substr[])
    {
        if(strlen(str)<strlen(substr))
            return false;
        for(int i=0;i<strlen(substr);i++)
        {
            if(str[i]!=substr[i])
            {
                return false;
            }
        }
        return true;
    }

private slots:
    void on_start_clicked();

    void on_btn_clicked();

private:
    Ui::MainWindow *ui;
    QImage pic;

    QTcpSocket  *tcpSocket;//通信套接字

    QByteArray recvBuf[MAX_PIC];

    int recvPlace;
    int pw,ph;
    double image_scale;

    bool isRunning;

    QTime time;
};

#endif // MAINWINDOW_H
